﻿using System;
using System.Collections.Generic;
using TI;
using System.IO;
using TiEntityObject.Transport;


namespace TiEntityObject.Transport
{
    /// <summary>
    /// Абстракция папки с транспортными файлами
    /// </summary>
    public class TransportFolder
    {
        public string FolderName { get; set; }
    
        public TransportFolder(string folderName)
        {
            FolderName = folderName;
          
        }

        public List<TransportFile> FileList { get { return PopulateFolderTransportList(this.FolderName); } }

        private List<TransportFile> PopulateFolderTransportList(string folderPath)
        {
            List<TransportFile> folderTransportList = new List<TransportFile>();
            
            string[] a = Helper.FileTools.GetFileList(folderPath, TransportConfig.Instance.FtpFileMask);
            foreach (string i in a)
            {
                folderTransportList.Add(new TransportFile(i, folderPath));
            }

            folderTransportList.Sort(TransportFile.Comparer);

            return folderTransportList;
        }

    }
}
